打印机调通

chengzhenyu 8 年之前
父節點
當前提交
4cbc07176e

+ 2 - 1
app/build.gradle

@@ -41,7 +41,7 @@ android {
41 41
             shrinkResources true
42 42
             debuggable false
43 43
             jniDebuggable false
44
-            buildConfigField "boolean", "isDevMode", "false"
44
+            buildConfigField "boolean", "isTestMode", "false"
45 45
             proguardFile 'proguard-project.txt'
46 46
             signingConfig signingConfigs.releaseConfig
47 47
         }
@@ -49,6 +49,7 @@ android {
49 49
             zipAlignEnabled false
50 50
             minifyEnabled false
51 51
             shrinkResources false
52
+            buildConfigField "boolean", "isTestMode", "false"
52 53
             signingConfig signingConfigs.releaseConfig
53 54
         }
54 55
     }

+ 1 - 1
app/src/main/java/ai/pai/lensman/printer/PrinterSettingActivity.java

@@ -128,7 +128,7 @@ public class PrinterSettingActivity extends BaseActivity implements PrinterSetti
128 128
         presenter.queryPrinterStatus();
129 129
     }
130 130
 
131
-    @OnClick(R.id.tv_print_test)
131
+    @OnClick(R.id.btn_print_qr)
132 132
     void printerQR(){
133 133
         presenter.printQR(qrcode);
134 134
     }

+ 7 - 19
app/src/main/java/ai/pai/lensman/printer/PrinterSettingPresenter.java

@@ -9,7 +9,6 @@ import android.content.Intent;
9 9
 import android.content.IntentFilter;
10 10
 import android.content.ServiceConnection;
11 11
 import android.os.IBinder;
12
-import android.os.RemoteException;
13 12
 import android.text.TextUtils;
14 13
 import android.util.Base64;
15 14
 import android.util.Log;
@@ -24,9 +23,7 @@ import com.gprinter.service.GpPrintService;
24 23
 
25 24
 import org.apache.commons.lang.ArrayUtils;
26 25
 
27
-import java.text.SimpleDateFormat;
28 26
 import java.util.ArrayList;
29
-import java.util.Date;
30 27
 import java.util.List;
31 28
 import java.util.Set;
32 29
 import java.util.Vector;
@@ -35,9 +32,6 @@ import ai.pai.lensman.App;
35 32
 import ai.pai.lensman.R;
36 33
 import ai.pai.lensman.db.Preferences;
37 34
 
38
-/**
39
- * Created by chengzhenyu on 2016/9/1.
40
- */
41 35
 
42 36
 public class PrinterSettingPresenter implements PrinterSettingContract.Presenter {
43 37
 
@@ -133,17 +127,11 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
133 127
             return;
134 128
         }
135 129
         EscCommand esc = new EscCommand();
136
-        esc.addPrintAndFeedLines((byte) 3);
137
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印居中
138
-        esc.addSelectPrintModes(EscCommand.FONT.FONTA, EscCommand.ENABLE.OFF, EscCommand.ENABLE.ON, EscCommand.ENABLE.ON, EscCommand.ENABLE.OFF);//设置为倍高倍宽
139
-        esc.addText("拍爱\n");   //  打印文字
140
-        esc.addPrintAndLineFeed();
141
-
142 130
 		/*打印文字*/
143 131
         esc.addSelectPrintModes(EscCommand.FONT.FONTA, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF);//取消倍高倍宽
144
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
145
-        esc.addText("欢迎使用拍爱!\n");   //  打印文字
146
-
132
+        esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印左对齐
133
+        esc.addText("拍爱\n");   //  打印文字
134
+        esc.addPrintAndLineFeed();
147 135
 		/*QRCode命令打印
148 136
 			此命令只在支持QRCode命令打印的机型才能使用。
149 137
 			在不支持二维码指令打印的机型上,则需要发送二维条码图片
@@ -153,10 +141,10 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
153 141
         esc.addStoreQRCodeData(qrCodeStr);//设置qrcode内容
154 142
         esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印中心对齐
155 143
         esc.addPrintQRCode();//打印QRCode
156
-        esc.addPrintAndFeedLines((byte) 3);
157
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
158
-        esc.addText("拍摄日期 "+new SimpleDateFormat("yyyy/MM/dd HH:mm").format(new Date()));
159
-        esc.addPrintAndFeedLines((byte) 3);
144
+        esc.addPrintAndFeedLines((byte) 1);
145
+//        esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
146
+//        esc.addText("拍摄日期 "+new SimpleDateFormat("yyyy/MM/dd HH:mm").format(new Date()));
147
+//        esc.addPrintAndFeedLines((byte) 2);
160 148
 
161 149
         Vector<Byte> datas = esc.getCommand(); //发送数据
162 150
         Byte[] Bytes = datas.toArray(new Byte[datas.size()]);

+ 3 - 0
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -11,6 +11,8 @@ import android.view.View;
11 11
 import android.widget.TextView;
12 12
 import android.widget.Toast;
13 13
 
14
+import com.android.common.utils.LogHelper;
15
+
14 16
 import ai.pai.lensman.R;
15 17
 import ai.pai.lensman.base.BaseActivity;
16 18
 import ai.pai.lensman.bean.PhotoBean;
@@ -141,6 +143,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
141 143
             if (data == null || data.getStringExtra("info") == null) {
142 144
                 return;
143 145
             }
146
+            LogHelper.d("qrcode","scan qrcode info = "+data.getStringExtra("info"));
144 147
         }
145 148
     }
146 149
 

+ 1 - 1
app/src/main/java/ai/pai/lensman/utils/BoxUrlContainer.java

@@ -2,7 +2,7 @@ package ai.pai.lensman.utils;
2 2
 
3 3
 public final class BoxUrlContainer {
4 4
 
5
-    private static final String BASE_URL = "http://192.168.1.191:8002/";
5
+    private static final String BASE_URL = "http://192.168.8.100:8002/";
6 6
 
7 7
     public static final String SESSION_START_URL = BASE_URL+"session_start";
8 8
 

+ 10 - 0
app/src/main/res/drawable/print_rounded_rect_bg.xml

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:shape="rectangle" >
4
+
5
+    <solid android:color="@color/colorPrimary" />
6
+
7
+    <corners
8
+        android:radius="4dp"/>
9
+
10
+</shape>

+ 19 - 20
app/src/main/res/layout/activity_printer_setting.xml

@@ -34,7 +34,7 @@
34 34
             android:gravity="center"
35 35
             android:paddingLeft="10dp"
36 36
             android:paddingRight="10dp"
37
-            android:text="@string/printer_settings"
37
+            android:text="@string/print_qr"
38 38
             android:textColor="@color/text_white"
39 39
             android:textSize="@dimen/action_bar_title_medium_text_size" />
40 40
 
@@ -72,6 +72,21 @@
72 72
             android:layout_gravity="center_horizontal"
73 73
             android:layout_margin="8dp"/>
74 74
 
75
+        <Button
76
+            android:id="@+id/btn_print_qr"
77
+            android:layout_width="wrap_content"
78
+            android:layout_height="wrap_content"
79
+            android:text="@string/print_qr"
80
+            android:layout_gravity="center_horizontal"
81
+            android:textSize="16sp"
82
+            android:textColor="@color/white"
83
+            android:background="@drawable/print_rounded_rect_bg"
84
+            android:layout_marginBottom="5dp"
85
+            android:paddingLeft="35dp"
86
+            android:paddingRight="35dp"
87
+            android:paddingBottom="5dp"
88
+            android:paddingTop="5dp"/>
89
+
75 90
         <LinearLayout
76 91
             android:layout_width="match_parent"
77 92
             android:layout_height="38dp"
@@ -98,30 +113,14 @@
98 113
 
99 114
             <TextView
100 115
                 android:id="@+id/tv_printer_status"
101
-                android:layout_width="wrap_content"
102
-                android:layout_height="wrap_content"
116
+                android:layout_width="match_parent"
117
+                android:layout_height="match_parent"
118
+                android:gravity="center_vertical"
103 119
                 android:text="@string/click_to_query"
104 120
                 android:textColor="@color/dark_grey"
105 121
                 android:textSize="16sp" />
106 122
         </LinearLayout>
107 123
 
108
-        <LinearLayout
109
-            android:layout_width="match_parent"
110
-            android:layout_height="42dp"
111
-            android:layout_marginTop="1dp"
112
-            android:background="@color/white"
113
-            android:gravity="center_vertical"
114
-            android:orientation="horizontal"
115
-            android:paddingLeft="12dp">
116
-
117
-            <TextView
118
-                android:id="@+id/tv_print_test"
119
-                android:layout_width="wrap_content"
120
-                android:layout_height="wrap_content"
121
-                android:text="@string/print_qr"
122
-                android:textColor="@color/dark_grey"
123
-                android:textSize="16sp" />
124
-        </LinearLayout>
125 124
 
126 125
         <LinearLayout
127 126
             android:layout_width="match_parent"